Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
trigram-utils
Advanced tools
trigram-utils
Trigram language statistics utility functions, in their own repository to make
sure trigrams
(trigram info for the universal declaration of
human rights) and franc
(language detection) use the same cleaning
and classification methods.
npm:
npm install trigram-utils
var utils = require('trigram-utils')
utils.clean(' t@rololol ') // => 't rololol'
utils.trigrams(' t@rololol ')
// => [ ' t ', 't r', ' ro', 'rol', 'olo', 'lol', 'olo', 'lol', 'ol ' ]
utils.asDictionary(' t@rololol ')
// => { 'ol ': 1, lol: 2, olo: 2, rol: 1, ' ro': 1, 't r': 1, ' t ': 1 }
var tuples = utils.asTuples(' t@rololol ')
// => [ [ 'ol ', 1 ],
// [ 'rol', 1 ],
// [ ' ro', 1 ],
// [ 't r', 1 ],
// [ ' t ', 1 ],
// [ 'lol', 2 ],
// [ 'olo', 2 ] ]
utils.tuplesAsDictionary(tuples)
// => { olo: 2, lol: 2, ' t ': 1, 't r': 1, ' ro': 1, rol: 1, 'ol ': 1 }
utils.clean(value)
Clean a given string: strips some (for language detection) useless punctuation, symbols, and numbers. Collapses white space, trims, and lowercases.
utils.trigrams(value)
Get clean, padded trigrams (see n-gram
).
utils.asDictionary(value)
Get clean trigrams as a dictionary: keys are trigrams, values are occurrence counts.
utils.asTuples(value)
Get clean trigrams with occurrence counts as a tuple: first index (0
) the
trigram, second (1
) the occurrence count.
utils.tuplesAsDictionary(tuples)
Transform an Array
of trigram–occurrence tuples (as returned by
asTuples()
) as a dictionary (as returned by
asDictionary()
)
FAQs
A few language trigram utilities
We found that trigram-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.